<?php
if (!defined('ROOT_PATH')) die('No direct access.');
function view_index($tipe){
	view_header_top();
	//----------------------------------------------------------------
	$title = "Realita - Beranda";
	$content = "Realita UMKM";
	$url = HOME_URL;
	$image = IMAGE_URL."300x240.gif";	//profpic orangnya / tokonya
	$desc = "Beranda sistem RealiTA UMKM";
	$auth = "RealiTA";
	$qwords = "utama, marketplace, umkm";
	//----------------------
	echo "<title>$title</title>";
	//<!--META DATA Open Graph-->
	echo "<meta property=\"og:title\" content=\"$title\"/>";
	echo "<meta property=\"og:type\" content=\"$content\"/>";
	echo "<meta property=\"og:url\" content=\"$url\"/>";
	echo "<meta property=\"og:image\" content=\"$image\"/>";
	echo "<meta property=\"og:site_name\" content=\"RealiTA UMKM\"/>";
	echo "<meta property=\"og:description\" content=\"$desc\" />";
	//<!--META DATA FB-->
	echo "<meta property=\"fb:app_id\" content=\"147346958657510\" />";
	//<!--META DATA-->
	echo "<meta name=\"author\" content=\"$auth\" />";
	echo "<meta name=\"keywords\" content=\"$qwords\" />";
	echo "<meta name=\"description\" content=\"$desc\" />";
	echo "<meta name=\"robots\" content=\"ALL\" />";
	echo "<meta charset=\"UTF-8\" />";
	//----------------------------------------------------------------
	view_header_bottom();
	$blaris = ($tipe=="barang_laris") ? '' : 'subheader';
	$bbaru = ($tipe=="barang_baru") ? '' : 'subheader';
	$tlaris = ($tipe=="toko_laris") ? '' : 'subheader';
	$tbaru = ($tipe=="toko_baru") ? '' : 'subheader';
	//
	switch($tipe){
		case "barang_laris" :
			$header = "Barang Laris";
			$contents = getBLaris();
			break;
		case "barang_baru" :
			$header = "Barang Baru";
			$contents = getBBaru();
			break;
		case "toko_laris" :
			$header = "Toko Laris";
			$contents = getTLaris();
			break;
		case "toko_baru" :
			$header = "Toko Baru";
			$contents = getTBaru();
			break;
	}
?>
    <!-- Normal Slider -->
      <div class="row">
        <div class="large-12 hide-for-small">
          <div id="featured">
              <img src="<?php echo IMAGE_URL ?>1200x500.gif" alt="slide image">
            </div>
      </div>
    </div>
    <!-- End Normal Slider -->
    <!-- Mobile Header -->
      <div class="row">
        <div class="large-12 columns show-for-small">
          <!--img src="http://placehold.it/1200x700&text=Mobile Header"-->
        </div>
      </div><br>
    <!-- End Mobile Header -->
    
    <!-- Content -->
      <div class="row">
        <div class="large-12 columns">
          <div class="row">
            <!-- Shows -->
            <div class="large-4 small-6 columns">
              <h4>Intip Pasar</h4><hr>
              <div class="row">
                <div class="large-1 column">
                  <!--img src="icon"-->
                </div>
                <div class="large-9 columns">
                  <h5 class="<?php echo $blaris; ?>"><a href="<?php echo HOME_URL."?tipe=barang_laris" ?>">Barang Laris</a></h5>
                </div>
              </div><hr>
              <!--div class="hide-for-small"-->
                <div class="row">
                  <div class="large-1 column">
                    <!--img src="icon"-->
                  </div>
                  <div class="large-9 columns">
                    <h5 class="<?php echo $bbaru; ?>"><a href="<?php echo HOME_URL."?tipe=barang_baru" ?>">Barang Baru</a></h5>
                  </div>
                </div><hr>
                <div class="row">
                  <div class="large-1 column">
                    <!--img src="icon"-->
                  </div>
                  <div class="large-9 columns">
                    <h5 class="<?php echo $tlaris; ?>"><a href="<?php echo HOME_URL."?tipe=toko_laris" ?>">Toko Laris</a></h5>
                  </div>
                </div><hr>
                <div class="row">
                  <div class="large-1 column">
                    <!--img src="icon"-->
                  </div>
                  <div class="large-9 columns">
                    <h5 class="<?php echo $tbaru; ?>"><a href="<?php echo HOME_URL."?tipe=toko_baru" ?>">Toko Baru</a></h5>
                  </div>
                </div>
              <!--/div-->
            </div>
            <!-- End Shows -->


            <!-- Image -->
            <div class="large-4 small-6 columns hide-for-small">
              <h4>Aktivitas Pasar</h4><hr>
              <div class="fb-activity" data-app-id="Display all actions associated with this app ID" data-site="http://9gag.tv/" data-action="likes, recommends" data-width="300px" data-height="365px" data-colorscheme="light" data-header="true"></div><br />
            </div>
            <!-- End Image -->

            <!-- Feed -->
            <div class="large-4 small-12 columns hide-for-small">
              <h4><?php echo $header; ?></h4><hr>
              <?php if (($tipe=='barang_laris')||($tipe=='barang_baru')) {
				//barang
				foreach ($contents as $feed) {
					echo "<div class=\"panel\">";
						echo "<h5><a href=\"".BARANG_URL.'a/'.$feed['idBarang'].'/'.$feed['slug-nama']."\">".$feed['nama']."</a></h5>";
						echo "<h6 class=\"subheader\">";
							echo int_to_rp($feed['harga']);
						echo "</h6>";
					echo "</div>";
				}
			  }else{
				//toko
				foreach ($contents as $feed) {
					echo "<div class=\"panel\">";
						echo "<h5><a href=\"".TOKO_URL.'a/'.$feed['idFB'].'/'.$feed['slug_nama-toko']."\">".$feed['nama-toko']."</a></h5>";
					echo "</div>";
				}
			  }
			?>
            </div>
            <!-- End Feed -->
<?php
	view_footer();
}
?>
